
import {
    increment,
    decrement,
    addValue,
    syncAddvalue
} from "./counterSlice";
import { useSelector, useDispatch } from "react-redux";
const ProductView = () => {
    // 获取仓库数据
    const count = useSelector(state => state.counter.value);
    // 获取修改仓库数据的工具
    const dispatch = useDispatch();
    return (
        <div>
            <p>
                仓库数据：{count}
            </p>
            <button onClick={() => dispatch(increment())}>+1</button>
            <button onClick={() => dispatch(decrement())}>-1</button>
            <button onClick={() => dispatch(addValue(5))}>+5</button>
            <button onClick={() => dispatch(syncAddvalue(10))}>两秒后+10</button>
        </div>
    );
};

export default ProductView;

